package IOperator;

import Book.*;
import java.sql.SQLException;
import java.util.Scanner;
import FileOperation.*;
public class AddBooks implements IOperator {
    @Override
    public void work(Bookshelf bookshelf) throws SQLException {
        //System.out.println("增加图书!");
        System.out.print("请输入你要增加图书的名字#-> ");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        System.out.print("请输入你增加图书的作者#-> ");
        String author = scanner.nextLine();
        System.out.print("请输入你要增加图书的价格#-> ");
        double price = scanner.nextDouble();

        scanner.nextLine();//去掉回车
        System.out.print("请输入你要增加图书的类型#-> ");
        String type = scanner.nextLine();

        Book book = new Book(bookName, author, price, type);
        bookshelf.setBooks(book);
        new saveBooks().fileSaveCover(bookshelf);

        System.out.println("新增图书成功!");
    }
}
